<%--
  Created by IntelliJ IDEA.
  User: MSI-CN
  Date: 2021/5/19
  Time: 16:35
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!--
@name:
@description:
@author: lzy
@title: 天王盖地虎!!!
@time: 2021-05-19 16:36:38
-->
<html lang="ch-CN">
<head>
    <meta charset="UTF-8">
    <title>添加关键词</title>
    <link rel="stylesheet" href="static/css/bootstrap.css">
    <style>
        #box {
            width: 500px;
            margin: 50px auto;
        }

        table {
            height: 20%;
            text-align: center;
            border: 1px solid #cccccc;
        }

        th {
            text-align: center;
            background-color: #b3b3b3;
        }

        tr:not(:last-child) td:nth-child(1){
            padding-top: 17px !important;   /*!important 最大权限*/
            background-color: #b3b3b3;
        }

        td {
            position: relative;
        }

        td span {
            width: 100px;
            position: absolute;
            right: -110px;
            top: 35%;
            display: block;
            text-align: left;
            font-size: 10px;
            color: #d92727;
        }

    </style>
</head>
<body>
<div id="box">
    <form action="" method="post">
        <table border="1px" class="table">
            <tr>
                <th colspan="3">我的工作笔记</th>
            </tr>
            <tr>
                <td>标题</td>
                <td>    <!--autocomplete="off"关闭表单记录数据-->
                    <input type="text" autocomplete="off" id="title" placeholder="" readonly="readonly" value="${working.title}" class="form-control">
                    <span></span>
                </td>
            </tr>

            <tr>
                <td>内容</td>
                <td>
                    <input type="text" id="neirong" placeholder="" readonly="readonly" value="${working.content}" class="form-control">
                    <span></span>
                </td>
            </tr>
            <tr>
                <td>类别</td>
                <td>
                    <input type="text" id="leibie" placeholder="" readonly="readonly" value="${working.typeName}" class="form-control">
                    <span></span>
                </td>
            </tr>
            <tr>
                <td>日期</td>
                <td>
                    <input type="text" id="riqi" placeholder="" readonly="readonly" value="${working.date}" class="form-control">
                    <span></span>
                </td>
            </tr>
            <tr>
                <td colspan="3">
                    <button type="button" class="btn btn-primary" id="sub">返回</button>
                </td>
            </tr>
        </table>
    </form>
</div>

<script src="static/js/jquery-3.5.1.js"></script>
<script>
    $(function (){
        $("#sub").click(function () {
            window.location.href="getAll";
        });
        $("form").submit(function (){
            if(check()){
            }else {
                return false;
            }
        });
        function check(){
            let flag = true;
            if($("#name").val().trim().length == 0){
                $("#name").next().html("请输入关键词");
                flag = false
            }else {
                if($("#name").val().trim().length < 1 || $("#name").val().trim().length > 15){
                    $("#name").next().html("关键词不能为空！");
                    flag = false
                }else {
                    $("#name").next().html("");
                }
            }
            if($("#time").val().trim().length == 0){
                $("#time").next().html("请输入日期");
                flag = false
            }else {
                let reg = /(?!0000)[0-9]{4}-((0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-8])|(0[13-9]|1[0-2])-(29|30)|(0[13578]|1[02])-31)/;
                if(reg.test($("#time").val())){
                    $("#time").next().html("");
                }else {
                    $("#time").next().html("格式不正确");
                    flag = false
                }
            }
            return flag;
        }
    });
</script>
</body>
</html>